package com.ruoyi.zhgd.controller;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zhgd.domain.vo.NLaboratoryMechanicsWFyDetailVo;
import com.ruoyi.zhgd.domain.bo.NLaboratoryMechanicsWFyDetailBo;
import com.ruoyi.zhgd.service.INLaboratoryMechanicsWFyDetailService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 万能机详情信息(3标)
 *
 * @author tll
 * @date 2023-09-15
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zhgd/laboratoryMechanicsWFyDetail")
public class NLaboratoryMechanicsWFyDetailController extends BaseController {

    private final INLaboratoryMechanicsWFyDetailService iNLaboratoryMechanicsWFyDetailService;

    /**
     * 查询万能机详情信息(3标)列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<NLaboratoryMechanicsWFyDetailVo> list(NLaboratoryMechanicsWFyDetailBo bo, PageQuery pageQuery) {
        return iNLaboratoryMechanicsWFyDetailService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出万能机详情信息(3标)列表
     */
    @SaCheckLogin
    @Log(title = "万能机详情信息(3标)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(NLaboratoryMechanicsWFyDetailBo bo, HttpServletResponse response) {
        List<NLaboratoryMechanicsWFyDetailVo> list = iNLaboratoryMechanicsWFyDetailService.queryList(bo);
        ExcelUtil.exportExcel(list, "万能机详情信息(3标)", NLaboratoryMechanicsWFyDetailVo.class, response);
    }

    /**
     * 获取万能机详情信息(3标)详细信息
     *
     * @param id 主键
     */
    @SaCheckLogin
    @GetMapping("/{id}")
    public R<NLaboratoryMechanicsWFyDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iNLaboratoryMechanicsWFyDetailService.queryById(id));
    }

    /**
     * 新增万能机详情信息(3标)
     */
    @SaCheckLogin
    @Log(title = "万能机详情信息(3标)", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody NLaboratoryMechanicsWFyDetailBo bo) {
        return toAjax(iNLaboratoryMechanicsWFyDetailService.insertByBo(bo));
    }

    /**
     * 修改万能机详情信息(3标)
     */
    @SaCheckLogin
    @Log(title = "万能机详情信息(3标)", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody NLaboratoryMechanicsWFyDetailBo bo) {
        return toAjax(iNLaboratoryMechanicsWFyDetailService.updateByBo(bo));
    }

    /**
     * 删除万能机详情信息(3标)
     *
     * @param ids 主键串
     */
    @SaCheckLogin
    @Log(title = "万能机详情信息(3标)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iNLaboratoryMechanicsWFyDetailService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
